/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tnviet.proj.jna.stat;

import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JDialog;
import jpcap.packet.Packet;

/**
 *
 * @author Administrator
 */
public abstract class JNStatDialog extends JDialog{

    JNStatDialog(Frame owner, String title, boolean modal) {
        super(owner, title, modal);
        jNStatDialogUpdater.start();
        this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    }


    abstract void fireUpdate();
    public abstract void addPacket(Packet p);
    public abstract void clear();
    public void startUpdating(){
        jNStatDialogUpdater.setRepeats(true);
        jNStatDialogUpdater.start();
    }

    public void stopUpdating(){
                jNStatDialogUpdater.stop();
                jNStatDialogUpdater.setRepeats(false);
                jNStatDialogUpdater.start();
    }

    javax.swing.Timer jNStatDialogUpdater=new javax.swing.Timer(1000,new ActionListener(){
            public void actionPerformed(ActionEvent evt){
                    fireUpdate();
                    repaint();
            }
    });

}
